package com.skyolder.milkbee.repository;

import com.skyolder.milkbee.domain.Favorite;
import com.skyolder.milkbee.service.dto.FavoriteDTO;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.*;

import java.util.HashMap;
import java.util.List;

/**
 * Spring Data JPA repository for the Favorite entity.
 */
@SuppressWarnings("unused")
public interface FavoriteRepository extends JpaRepository<Favorite,Long> {

	List<Favorite> findByCardIdAndUserId(Long cardId, Long userId);
	
	Page<Favorite> queryByUserId(Long userId, Pageable pageable);
	//@Query(nativeQuery = true,value="select f.id as id,f.card_id as card_id,f.user_id as user_id,f.leaguer_id  as leaguer_id,f.created_at as created_at,c.title as title,c.author as author,c.created_at as posted_at from favorite as f left join card as c on f.card_id=c.id  where f.user_id=?1 ",countQuery = "select count(1) from userinfo u where u.name=?1")
	
}
